from pylons import g
def mime_type(content_type):
    ''' Given leonardo content type, return mime type '''
    t={'png':'image/png','jpg':'image/jpg','jpeg':'image/jpeg',
                'pdf':'application/pdf','xml':'application/xml',
                'css':'text/css','txt':'text/plain',
                'htm':'text/html','html':'text/html'}
    if content_type in t: 
       ct=t[content_type]
    else: ct='application/%s'%content_type
    return ct
def mime_image(mime_type):
    ''' Given a mime type, choose an image for leonardo to display '''
    #image dir could be chosen from a config file to override look n feel
    imgdir='%sicons'%g.home_href
    print mime_type
    images={'image':'%s/image.png'%imgdir,
            'application/pdf':'%s/pdf.png'%imgdir,
            'text/html':'%s/html.png'%imgdir,
            'folder':'%s/folder.png'%imgdir}
    if mime_type.startswith('image'): mime_type='image'
    #default:
    if mime_type not in images: mime_type='text/html'
    print mime_type,images[mime_type]
    return images[mime_type]
        
            